<template>
	<view>
		<!-- <view class="">token:{{$store.state.user.token}}</view> -->
		<view class="">token:{{token}}</view>
		<view class="">token2:{{token2}}</view>
		<view class="main-text-color">【不推荐使用$store】在微信小程序中获取不到数据。</view>
		<view class="">$store:{{$store.state.user.token}}</view>
		<button type="default" @click="saveToken">bbb</button>
	</view>
</template>

<script>
	import {
		mapState,
		mapGetters,
		mapMutations,
		mapActions
	} from 'vuex'

	export default {
		data() {
			return {}
		},
		onLoad() {
			// console.log(this.$store.state.user.token);
			// console.log(JSON.stringify(this.$store.state.user.test));
			// console.log(JSON.stringify(this.$store.state.user.userInfo));
			// console.log(JSON.stringify(this.$store.state.user));
		},
		computed: {
			token() {
				return this.$store.state.user.token
			},
			...mapState({
				token2: state => state.user.token,
				// name: state => state.user.name,
			}),
		},
		methods: {
			...mapMutations(['setToken']),
			saveToken() {
				this.$store.commit('setToken', '444')
				console.log('ssstoken');
			}
		},
	}
</script>

<style scoped>

</style>